
//define this here to avoid introducing anything 
// to the global namespace.
var js = {};

module("Types ", {
  setup : function() {
  },
  teardown: function() {
  }
});

test("Export Symbol: baseline", function() {
	
	//a negative control of an object which is not exported.
	(function() {
		
		var TestObject = {
			foo:'bar'
		}
		
	})();
	
	ok(typeof TestObject === 'undefined');
});

test("Export Symbol: export", function() {
	
	(function() {
		var TestObject = {
			foo:'bar'
		}
		Types.exportSymbol("js.test1.TestObject", TestObject);
	})();
	
	ok(typeof js.test1.TestObject != 'undefined');
	equal(js.test1.TestObject.foo, 'bar');
});

test("Export Symbol: import", function() {
	
	(function() {
		
		var TestObject2 = {
			foo:'bar2'
		}
		Types.exportSymbol("js.test1.TestObject2", TestObject2);
	})();
	
	Types.importSymbol("js.test1.TestObject2");
	ok(typeof TestObject2 != 'undefined');
	equal(TestObject2.foo, 'bar2');
});

test("Export Symbol: import (scoped)", function() {
	
	(function() {
		
		var TestObject2 = {
			foo:'bar2'
		}
		Types.exportSymbol("js.test1.TestObject2", TestObject2);
	})();
	
	var mynamespace = {};
	
	Types.importSymbol("js.test1.TestObject2", mynamespace);
	ok(typeof mynamespace.TestObject2 != 'undefined');
	equal(mynamespace.TestObject2.foo, 'bar2');
});

test("Interface: negative controll", function() {
	
	(function() {
		
		var ITestInterface = {
			method1: function(foo, bar) {},
			method2: function(foo) {}
		}
		Types.exportInterface("js.testifs.ITestInterface", ITestInterface);
		
	})();
	
	var TestObject = {
		
	}
	
	ok( !  Types.doesImplement(TestObject, js.testifs.ITestInterface));
});

test("Interface: does implement", function() {
	
	(function() {
		
		var ITestInterface = {
			method1: function(foo, bar) {},
			method2: function(foo) {}
		}
		Types.exportInterface("js.testifs.ITestInterface2", ITestInterface);
		
	})();
	
	var TestObject2 = {
		method1: function(foo, bar) {},
		method2: function(foo) {}
	};
	
	ok(  Types.doesImplement(TestObject2, js.testifs.ITestInterface2));
});

test("Interface: wrong argument counts", function() {
	
	(function() {
		
		var ITestInterface = {
			method1: function(foo, bar) {},
			method2: function(foo) {}
		}
		Types.exportInterface("js.testifs.ITestInterface", ITestInterface);
		
	})();
	
	var TestObject1 = {
		method1: function(foo) {},
		method2: function(foo) {}
	};
	var TestObject2 = {
		method1: function(foo) {},
		method2: function(foo, bar) {}
	};
	var TestObject3 = {
		method1: function(foo, baz) {},
		method2: function(foo, bar) {}
	};
	
	ok( ! Types.doesImplement(TestObject1, js.testifs.ITestInterface));
	ok( ! Types.doesImplement(TestObject2, js.testifs.ITestInterface));
	ok( ! Types.doesImplement(TestObject3, js.testifs.ITestInterface));
});

